<template>
    <main>
        <div class="publish" :class="{ publish_lock: store.state.publish_lock }">
            <h1>项目展示</h1>
            <!-- <div v-for="item in 3" :key="item" class="test_box_class">{{ item }}</div> -->
            <!-- <div v-for="item1 in text1" :key="item1">{{ item1 }}</div> -->
            <div class="pu_body">
                <div class="el_main a" v-for="item1 in textData" :key="item1.id" @click="openShowView(item1.title)">
                    <div class="el_body">
                        <div class="el_title">{{ item1.title }}</div>
                        <div class="el_desc">{{ item1.desc }}</div>
                    </div>
                    <div class="el_time">{{ item1.time }}</div>
                </div>
            </div>
        </div>
        
        <Transition name="showView">
            <ShowView :time="time" :name="name" :isopen="isopen" />
        </Transition>
    </main>

</template>
<script setup>
import { ref, onMounted } from 'vue';
import { useStore } from 'vuex'
const store = useStore()

import { textData } from '/public/js/text.js';

import ShowView from './ChildViews/ShowView.vue'
const name = ref("")
const isopen = ref(false)
const time = ref(0)


function openShowView(value) {
    time.value++
    name.value = value
    isopen.value = true
    store.state.publish_lock = true
}
</script>
<style scoped>
main {
    position: relative;
    min-height: calc(100vh - var(--headerHeight));
    width: 100%;
}

.publish {
    text-align: center;
    max-width: 1200px;
    margin: auto;
}

.pu_body {
    padding-block: 20px;
    margin-left: 10px;
    margin-right: 10px;
    display: grid;
    grid-template-rows: 1fr;
    grid-row-gap: 20px;
}

.el_main {
    background-color: aliceblue;
    border-radius: 6px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.el_body {
    text-align: left;
}

.el_title {
    font-size: 20px;
    color: #009e69;
    transition: 0.3s;
}

.el_main:nth-child(2n) .el_title {
    color: #ff922b;
}

.el_title:hover {
    text-decoration: underline;
}

.el_desc {
    font-size: 14px;
    color: #838383;
}

.el_time {
    font-size: 18px;
}

.showView-enter-active,
.showView-leave-active {
    transition: 0.4s ease-in-out;
}

.showView-enter-from,
.showView-leave-to {
    transform: translateX(100%);
}
</style>